<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>CK宠物网  admin 管理文章</title>
    <jsp:include page="top_utils.jsp"></jsp:include>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/myplace.css"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/myspace.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/my_adopt.css">
  </head>
  
  <body>
 	<!-- 头部-->
	<div class="headnav">
		<div class="topBar">
			<div class="topBarL">
				<jsp:include page="logo.jsp"></jsp:include>
				<div class="nav">
					<ul>
						<li>
							<a href="${pageContext.request.contextPath }/">首页</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/news/">新闻</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/adopt/">领养</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/knowledge/">知识</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/shopping/">商城</a>
						</li>
					</ul>
				</div>
			</div>

			<jsp:include page="topBarR.jsp"></jsp:include>
		</div>
	</div>
 	
	<div id="main" style="background:url('/dogstore/images/${user.backimg}')  no-repeat center top;">
	  <jsp:include page="my_top.jsp"></jsp:include>
	  
	  <div class="layout-body">
	    <div class="w960  clf">   
	      <div class="m_main">
	        <div class="inner centers_mr"> 
     			<c:if test="${user.issale_power == 0 }">
     				<div class="public_m2">管理员可对文章做任何操作!</div>
     			</c:if>
     			<a class="layui-btn layui-btn-small" href="${pageContext.request.contextPath }/user/myspace">返回个人主页</a>
				<a class="layui-btn layui-btn-small" onclick="javascript:history.back(-1);">返回上一步</a>
				<br/>
				<br/>
	     		<div class="tip_notem">
	     			<br/>
	     			
	     			<style>
	     				.layui-table th{
	     					font-size:15px;
	     					font-weight:bold;
	     					float:none;
	     				}
	     			</style>
	            	<fieldset class="layui-elem-field site-demo-button">
					  <legend>文章列表</legend>
					  	 <a class="layui-btn layui-btn-radius layui-btn-normal" style="margin-top:10px;"><i class="layui-icon">&#xe608;</i>添加文章</a>
					  	 <blockquote class="layui-elem-quote layui-quote-nm" style="float:right">
					  	 	排序
					  	 	<a class="layui-btn layui-btn-mini" href="${pageContext.request.contextPath}/user/my_articles">时间</a>
					  	 	<a class="layui-btn layui-btn-mini" href="${pageContext.request.contextPath}/user/my_articles_hot">热度</a>
					  	 	类别
							<a class="layui-btn layui-btn-mini" href="${pageContext.request.contextPath}/user/my_articles_news">新闻</a>
							<a class="layui-btn layui-btn-mini" href="${pageContext.request.contextPath}/user/my_articles_know">知识</a>
					  	 </blockquote>
					  	 <br/>
					  	 <br/>
					     <c:if test="${isnull == '1'}">
							<div class="layui-form">
							  <table class="layui-table">
							    <colgroup>
							      <col width="20%">
							      <col width="10%">
							      <col width="10%">
							      <col width="10%">
							      <col width="10%">
							      <col width="10%">
							      <col width="15%">
							      <col width="15%">
							    </colgroup>
							    <thead>
							      <tr>
							      	<th>标题</th>
							        <th>类别</th>
							        <th>封面</th>
							        <th>浏览量</th>
							        <th>评论量</th>
							        <th>热度</th>
							        <th>发表时间</th>
							        <th>操作</th>
							      </tr> 
							    </thead>
							    <tbody>
							      <c:forEach items="${list }" var="ado">
							      	 <tr>
								        <td>
								        	<a href="javascript:" style="font-size: 5px;">${ado.title }</a>
								        </td>
								        
								        <td>${ado.type.name }</td>
								        
								        <td><img style="border-radius:5px;" src="${ado.imgurl }" width="50px;" height="50px;"></td>
								        
								        <td>${ado.looknum }</td>
								        
								        <td>${ado.remarknum }</td>
								        
								        <td>${ado.hotnum }</td>
								        
								        <td>${ado.uptime }</td>
											
								        <td>
								        	<div class="button-group">
								        		<input type="hidden" value="${user.id }" id="user_id" /> 
								        		<a class="layui-btn layui-btn-small layui-btn-warm" id="${ado.id }" title="编辑" href="javascript:void(0)" onclick="edit(this.id);">
								        			<i class="layui-icon" style="font-size: 25px;">&#xe60a;</i>
								        		</a>
								        		<a class="layui-btn layui-btn-small layui-btn-warm" id="${ado.id }" title="删除" href="javascript:void(0)" onclick="del(this.id);">
								        			<i class="layui-icon" style="font-size: 25px;">&#xe640;</i>
								        		</a>
								        	</div>
								        </td>
								     </tr>
							      </c:forEach>
							    </tbody>
							  </table>
							</div>						     
					     </c:if>
					     <c:if test="${isnull == '0'}">
					     	<h2>没有文章...</h2>
					     	<br/>
					     	<br/>
					     	<c:if test="${user.issale_power == 1 }">
			     				<a class="layui-btn layui-btn-small" href="${pageContext.request.contextPath}/jsps/client/my_editAdopt.jsp">去发布</a>
			     			</c:if>
					     </c:if>
					  </div>
					</fieldset>
	            </div>
	        </div>
	      </div>
	      
	    </div>
	  </div>
	</div>
	
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/my_adopt.css">
	<jsp:include page="footer.jsp"></jsp:include>
  </body>
  <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/head.js"></script>
  <script>
  	window.onload=function (){
		if(${user == null}){
			layer.msg("你未登录!",{shift: 6});
			setTimeout(function (){
				window.location.href="/dogstore/";
			},1500);
		}
 	};
 	
 	
 	$(document).ready(function(){
 		
 	});
 	
 	function del(id){
 		var user_id = $("#user_id").val();
 		layer.confirm('确定删除此文章？', {
			btn: ['确定','取消'] //按钮
		}, function(){
			//确定
		  	var index = layer.load(1, {time: 10000});;
		  	$.ajax({
	 			type:"post",
				url:"/dogstore/user/deleteArticle.action",
				async:false, 
	 			data:{
	 				id:id
	 			},
	 			success:function (error){
	 				if(error == "0"){
	 					layer.close(index);
	 					layer.msg("删除成功!",{icon: 1,shift: 1});
	 					setTimeout(function (){
							//刷新
							window.location.reload();
						},1000);
	 				}else{
	 					layer.close(index);
	 					layer.msg("数据删除失败!请联系prince!500",{icon: 2,shift: 6});
	 				}
	 			},
	 			error:function (){
	 				layer.close(index);
	 				layer.msg("提交失败!请联系prince!",{icon: 2,shift: 6});
	 			} 			
	 		},"json");
		}, function(){
			//取消
		 	return; 
		});
 		
 	}
  </script>
</html>
